<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>课程列表</title>
    <style>
        table { border-collapse: collapse; width: 100%; }
        th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
        th { background-color: #f2f2f2; }
        tr:hover { background-color: #f5f5f5; }
        .btn { padding: 5px 10px; text-decoration: none; border-radius: 3px; }
        .btn-add { background-color: #4CAF50; color: white; }
        .btn-edit { background-color: #008CBA; color: white; }
        .btn-delete { background-color: #f44336; color: white; }
    </style>
</head>
<body>
<h2>课程列表</h2>
<a href="${pageContext.request.contextPath}/course/add" class="btn btn-add">添加课程</a>
<table>
    <tr>
        <th>课程ID</th>
        <th>课程代码</th>
        <th>课程名称</th>
        <th>教师ID</th>
        <th>学分</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${courses}" var="course">
        <tr>
            <td>${course.courseid}</td>
            <td>${course.course}</td>
            <td>${course.name}</td>
            <td>${course.teacher_id}</td>
            <td>${course.credit}</td>
            <td>
                <a href="${pageContext.request.contextPath}/course/edit/${course.courseid}" class="btn btn-edit">编辑</a>
                <a href="${pageContext.request.contextPath}/course/delete/${course.courseid}" class="btn btn-delete" onclick="return confirm('确定要删除吗?')">删除</a>
                <a href="${pageContext.request.contextPath}/course/detail/${course.courseid}">详情</a>
            </td>
        </tr>
    </c:forEach>
</table>
</body>
</html>